from sort.Sort import Sort


class SelectSort(Sort):
    """
    选择排序的实现
        从无序子数组中选择最小的值往数组有序子序列从前往后依次放置
    """
    def __init__(self):
        super().__init__()

    def sort(self, arr_list):
        length = len(arr_list)
        for i in range(0, length - 1):
            minIndex = i
            for j in range(i + 1, length):
                if arr_list[minIndex] > arr_list[j]:
                    minIndex = j
            Sort.swap(arr_list, i, minIndex)
        return arr_list


if __name__ == '__main__':
    arr = [2, 5, 3, 7, 1, 4]
    print(arr)
    sort = SelectSort()
    print(sort.sort(arr))
